import React, { Fragment, useEffect, useState } from "react";
function Alert() {
    let [num, setNum] = useState(0);
    let [time, setTime] = useState(new Date().getTime())
    useEffect(() => {
        console.log("====time change====")
    }, [time])
    const increment = () => {
        setNum(num => num += 1)
    }
    const gettime = () => {
        setTime(time => time = new Date().getTime())
    }
    return (
        <Fragment>
            <div className="mt-3 alert alert-danger">当前数值为：{num}</div>
            <div className="mt-3 alert alert-info">当前时间为：{time}</div>
            <button className="btn btn-primary" onClick={increment}>自增</button>
            <button className="ml-3 btn btn-success" onClick={gettime}>当前时间</button>
        </Fragment>
    )
}

export default Alert